# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Gleidson <gleidson.echeli@gmail.com>

pkgname=emacs-haskell-mode
pkgver=17.2
pkgrel=3
_commit=20d4e2300302a9af673e82d0185d3f489bfb0f59
pkgdesc="Haskell mode package for Emacs"
arch=(any)
license=('GPL')
url="https://github.com/haskell/haskell-mode"
install=emacs-haskell-mode.install
makedepends=('emacs')
#source=($pkgname-$pkgver.tar.gz::https://github.com/haskell/haskell-mode/archive/$pkgver.tar.gz)
source=($pkgname-${_commit}.tar.gz::https://github.com/haskell/haskell-mode/archive/${_commit}.tar.gz)
sha256sums=('22b9f31c554bac1591ec52d2c459ae96ff89e076f5857ee29d03df1ead7ccb08')

prepare() {
#  cd "$srcdir"/haskell-mode-$pkgver
  cd "$srcdir"/haskell-mode-${_commit}
  sed -i 's|haskell-mode-pkg.el,|haskell-mode-pkg.el haskell-mode.el,|' Makefile
}

build() {
#  cd "$srcdir"/haskell-mode-$pkgver
  cd "$srcdir"/haskell-mode-${_commit}
  export EMACS=/usr/bin/emacs
  make
}

package() {
#  cd "$srcdir"/haskell-mode-$pkgver
  cd "$srcdir"/haskell-mode-${_commit}

  install -dm0755 "$pkgdir"/usr/share/emacs/site-lisp/haskell-mode
  install -m0644 *.el -t "$pkgdir"/usr/share/emacs/site-lisp/haskell-mode
  cp -a build-$(emacs --version | head -n1 | cut -f3 -d' ') -t "$pkgdir"/usr/share/emacs/site-lisp/haskell-mode/

  install -dm0755 "$pkgdir"/usr/share/doc/$pkgname
  install -m0644 NEWS README.md "$pkgdir"/usr/share/doc/$pkgname

  install -Dm0644 haskell-mode.info "$pkgdir"/usr/share/info/haskell-mode.info
}
